package com.daydayup.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by Administrator on 2019/4/22/022.
 */
public class StreamTest2 {
    public static void main(String[] args) {
        Stream<String> stream = Stream.generate(()->"user").limit(20);
        stream.forEach(System.out::println);
//        stream.forEach(System.out::println);

        List<Student> students = new ArrayList<Student>();
        for (int i = 0; i < 10; i++) {
            Student student = new Student();
            student.setName("张三" + i);
            student.setAge(i);
            students.add(student);
        }
        List<Student> stus1 = students.stream().filter(e -> e.getAge() > 3).collect(Collectors.toList());
        Stream<Student> stream1 = students.stream();
        System.out.println("stream1"+stream1);
        Stream<Student> stream2 = students.stream();
        System.out.println("stream2"+stream2);
        stream1.forEach(e -> System.out.println(e.getAge()));
        stream1.forEach(e -> System.out.println(e.getAge()));
    }
}
